-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add selecting network circuit #621
Conversation
merged = Array(Signal(self.layout) for _ in range(total_len)) | ||
|
||
for i in range(len(a)): | ||
m.d.comb += merged[i].eq(Mux(cnt_a <= i, b[i - cnt_a], a[i])) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This generates a lot of subtractors. Why you doesn't use shifts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it is a problem. These are not proper substractions. In fact, the synthesis tool can permutate inputs of the mux and simply address it using cnt_a
.
Shifting by variable number of bits in particular won't be better than a mux.
|
||
|
||
@parameterized_class( | ||
("n"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be ("n",)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for pointing this out - it should. However, apparently this decorator correctly handles this case:
if isinstance(attrs, string_types):
attrs = [attrs]
I didn't call it sorting network, because in fact it doesn't sort -- we don't care about items that are not valid. We only select valid inputs and group them together.
The generated circuit looks nice (n=6):
https://digitaljs.tilk.eu/#2cde77f56b8cfd56a81defc25c4adc6257fc3f60f78f301a38ddc4a7d7330310